﻿@inherits Project.Engine.Control.BasePageRazor
@{
    ViewBag.Title = "Chỉnh sửa bài viết";
    Layout = "~/Views/Backend/Home/_Master.cshtml";
    Project.Module.View.CMS.CMSEditNewsView view = this.Model.DocumentObject as Project.Module.View.CMS.CMSEditNewsView;
}
<h2>Chỉnh sửa bài viết</h2>
<table height="20px"></table>
        <form method="post">
        <table border="0">
        	<tr>
            	<td>Tiêu đề bài viết</td>
            	<td><input type="text" id="name" class="inp-form" value="@view.news.title"/></td>
            </tr>
            <tr height="10px"></tr>
            <tr>
            	<td>Nội dung</td>
                <td><textarea rows="" cols="" id="description" class="form-textarea" value="@view.news.content"></textarea></td>
            </tr>
            <tr height="10px"></tr>
            <tr>
            	<td>Hiển thị</td>
            	<td><input type="checkbox" id="status" /></td>
            </tr>
            <tr height="10px"></tr>
            <tr>
            	<td><input type="submit" id="btnAdd" class="add-form" /></td>&nbsp;&nbsp;
                <td><input type="submit" id="btnCancel" class="reset-form" /></td>
            </tr>
        </table>
        </form>
<table height="20px"></table>

<script type="text/javascript">
    $('#btnAdd').click(function () {
        var link = '/admin/editNews';
        var newId = window.location.href;
        var name = document.getElementById('name').value;
        var status = document.getElementById('status').checked;
        var description = document.getElementById('description').value;

        $.post(link, {'id': newId, 'title': name, 'status': status, 'content': description }, function (data) {
            if (data.result == 1) {
                window.location = "/admin/quan-ly-bai-viet";
            }
        });

        document.getElementById('name').value = '';
        document.getElementById('status').checked = false;
        document.getElementById('description').value = '';

        // return
        return false;
    });

    $('#btnCancel').click(function () {
        document.getElementById('name').value = '';
        document.getElementById('status').checked = false;
        document.getElementById('description').value = '';

        // return
        return false;
    });
</script>

